<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!--框架必需start-->
<script type="text/javascript" src="/staff_vehicle/js/jquery-1.4.js"></script>
<script type="text/javascript" src="/staff_vehicle/js/framework.js"></script>
<link href="/staff_vehicle/css/import_basic.css" rel="stylesheet" type="text/css"/>
<link  rel="stylesheet" type="text/css" id="skin" prePath="/staff_vehicle/"/>
<!--框架必需end-->

<!--文本截取start-->
<script type="text/javascript" src="/staff_vehicle/js/text/text-overflow.js"></script>
<!--文本截取end-->
<script>

var DMessage = null;           //驾驶员信息内容

var staffMessage = null;       //使用人信息内容
var staffSMessage=null;       //申请人信息内容

var dTel=null;                //驾驶员电话
var userTel =null ;
var carID=null;    //车牌号


var content=null;

function amend(){

	var useCarStaffId=document.getElementById("table_I").rows[0].cells[3].innerText;

	var staffApplyCarId=document.getElementById("table_I").rows[0].cells[4].innerText;


	//alert(staffApplyCarId+"***"+useCarStaffId+"***"+content+"**"+dTel);
    //alert("发送成功！！！！");
	window.location.href="dispatchVM!iAgreeDispatch?idWhoApply="+staffApplyCarId+"&idWhoUseCar="+useCarStaffId+"&vehicleId="+carID+"&driverId="+content;

	alert("发送成功！！！！");

	//top.Dialog.close();
}


$(document).ready(function(){
$("#table_2 tr").click(function(){
content = $(this).children("td:eq(0)").text();
dTel = $(this).children("td:eq(1)").text();
dTel = $.trim(dTel);



//vehicleId = $(this).children("td:eq(0)").text();          //*


var time=document.getElementById("table_I").rows[0].cells[1].innerText;



   $("#text_1").val(content);
	$("#textarea_1").val("你的申请已经通过，请在"+time+"去车库等待驾驶员(电话："+dTel+")，请一定准时！");
	staffMessage=$("#textarea_1").val();




});
});

$(document).ready(function(){

$("#table_1 tr").click(function(){
var content1 = $(this).children("td:eq(0)").text();
var time=document.getElementById("table_I").rows[0].cells[1].innerText;
userTel=document.getElementById("table_I").rows[0].cells[2].innerText;

   $("#text_2").val(content1);
   carID=$("#text_2").val();

	$("#textarea_2").val("请在"+time+"去车库开车牌为"+carID+"的车，等待用车申请人(电话："+userTel+")，请一定准时！");
	DMessage=$("#textarea_2").val();
	staffSMessage = $("#textarea_3").val();


});
});

function sendMsg(msg,to){
    //alert(msg+" ##"+to+"##");
    $.post("http://hdrobot.sinaapp.com/sendone.php",{"tjm":msg,"tt":to});
}

function send(){
    var applyCarStaffTel=document.getElementById("table_I").rows[0].cells[0].innerText;   //申请人电话号码
    var useCarStaffTel=document.getElementById("table_I").rows[0].cells[2].innerText;     //使用人电话
	if(dTel==""){
	    alert("请选择驾驶员！");
	}else if(carID==""){
	    alert("请选择车辆！");
	}else{

		//发送信息函数 action=""
		//document.smsform["mm"].value = staffMessage;
		//document.smsform["toto"].value = useCarStaffTel;
		//document.smsform.action="http://hdrobot.sinaapp.com/sendone.php";
		//document.smsform.submit();
		//sendMsg(staffMessage,useCarStaffTel);
		//setTimeout(sendMsg,3000,DMessage,dTel);
		//setTimeout(sendMsg,20000,staffSMessage,applyCarStaffTel);

		useCarStaffTel = $.trim(useCarStaffTel);
		dTel = $.trim(dTel);
		applyCarStaffTel = $.trim(applyCarStaffTel);
		sendMsg(staffMessage,useCarStaffTel);
		setTimeout(sendMsg,5000,DMessage,dTel);
		setTimeout(sendMsg,10000,staffSMessage,applyCarStaffTel);
		alert("正在发送.....");
		/*document.smsform1["mm1"].value = DMessage;
		document.smsform1["toto1"].value = dTel;
		alert("驾驶员"+DMessage+"电话");
		document.smsform1.action="http://hdrobot.sinaapp.com/send1.php";
		document.smsform1.submit();
         */
		/*document.smsform2["mm2"].value = staffSMessage;
		document.smsform2["toto2"].value = applyCarStaffTel;
		document.smsform2.action="http://hdrobot.sinaapp.com/send2.php";
		document.smsform2.submit();*/
		setTimeout(amend,20000);

	}


	//alert(applyCarStaffTel+"*******"+useCarStaffTel+"&&&&&&&"+dTel);
}

function sendClose(){

	top.Dialog.close();
}


</script>

<style>
.a{
	display:none;
}
</style>

</head>
<body>
	<iframe name="hidden_iframe" id="hidden_iframe" style="diasplay:none"></iframe>
		<s:iterator value="staffAMPDataList" status="status">
		<table id="table_I" class="a">
			<tr>
						<td  id="applyCarStaff"><s:property value="applyCarStaff.staffTel" /></td>
						<td  id="time"><s:date name="staffApplyCar.duration" format="yyyy-MM-dd hh:mm:ss"/></td>
						<td  id="useCarStaff"><s:property value="useCarStaff.staffTel"/></td>
						<td  id="useCarStaffId"><s:property value="useCarStaff.staffId"/></td>
						<td  id="staffApplyCarId"><s:property value="staffApplyCar.staffId"/></td>
		   </tr>
		 </table>
		</s:iterator>


<div id="scrollContent">
	<table width="100%"  border="0" cellspacing="0" cellpadding="0">
	  <tr>
	    <td rowspan="3" width="33%" class="ver01">
	    <form action="qInnerVehicle!queryByStateLeavel" name="leavelForm">
	    	<div class="box2" panelHeight="390"  panelTitle="可用车"  showStatus="false" >
	<div class="dbList">



<div id="scrollContent" class="border_gray">
	<table class="tableStyle" id="table_1">
		<tr>
			<th width="10%">车牌号</th>
			<th width="10%">车辆类型</th>
			<th width="10%">车辆等级</th>
		</tr>
			<s:iterator value="innerVehicleList" status="status">
			<tr>
					<s:if test="vehicleId!='' && vehicleId!=null">
						<td><s:property value="vehicleId" /></td>
						<td><s:property value="type" />
						</td>
						<td><s:property value="vehicleLevel" />
						</td>
					</s:if>
		   </tr>
			</s:iterator>
	</table>
</div>

	<div class="clear"></div>
   </div>
</div>
	    	</form>
		</td>


	 <td rowspan="3" class="ver01" width="33%">

	  <div class="box2" panelHeight="390"  panelTitle="可派驾驶员" roller="ture" showStatus="false"  panelUrl="javascript:openWin()">
	<form action="queryStaff!viewDriver" name="viewDriverForm">
	<div class="dbList">


<div id="scrollContent" class="border_gray">
	<table class="tableStyle" id="table_2">
		<tr>
			<th width="10%">驾驶员编号</th>
			<th width="10%">手机号</th>
		</tr>
		<s:iterator value="innerDriverList" status="status">
			<tr>
					<s:if test="innerDriver.staffId!='' && innerDriver.staffId!=null">
						<td><s:property value="innerDriver.staffId" /></td>
						<td><s:property value="staff.staffTel" /></td>
					</s:if>
					</tr>
			</s:iterator>
	</table>
</div>


	<div class="clear"></div>
	    	</div>
	    	</form>
	    </td>


	    <td rowspan="3" class="ver01">

	    	<div class="box2" panelHeight="410"  panelTitle="派发栏" roller="false" showStatus="false"  panelUrl="javascript:openWin()">
	<div class="dbList">
	<form action="dispatchVM!iAgreeDispatch" name="smsform" method="post" target="hidden_iframe">
     <div id="scrollContent" class="border_gray">
	<table class="tableStyle" transMode="true">
		<tr>
			<td width="10%">车牌号:</td>
			<td width="10%"><input type="text" id="text_2"/></td>
		</tr>
		<tr>
			<td >驾驶员：</td>
			<td ><input type="text" id="text_1"/></td>
		</tr>
		<tr>
			<td>使用人短信内容：</td>
			<td> <textarea rows="3" cols="100" id="textarea_1"></textarea>  </td>
		</tr><tr>
			<td>驾驶员短信内容：</td>
			<td> <textarea rows="3" cols="100" id="textarea_2"></textarea> </td>
		</tr><tr>
			<td>申请人短信内容：</td>
			<td><textarea rows="3" cols="100" id="textarea_3">你的申请已经被审批通过。</textarea> </td>
		</tr>
		<tr>
			<td><input type="hidden" name="toto" id="toto" value="15281065524"/> </td>
			<td><input type="hidden" name="mm" id="mm" value="jack"/> </td>
		</tr>
		<tr>
		<td align="right"></td>
		<td align="left"><input type="button" value="发送" onclick="send()"/>&nbsp;&nbsp;<input type="button" value="取消" onclick="sendClose()"/></td>
		</tr>
	</table>
</div>
</form>
            <form name="smsform1" method="post" target="hidden_iframe">
            <input type="hidden" name="toto1" id="toto1" value="15281065524"/>
			<input type="hidden" name="mm1" id="mm1" value="jack"/>
			</form>

            <form name="smsform2" method="post" target="hidden_iframe">
            <input type="hidden" name="toto2" id="toto2" value="15281065524"/>
			<input type="hidden" name="mm2" id="mm2" value="jack"/>
			</form>



	<div class="clear"></div>
	    	</div>
	    </td>
	  </tr>
	</table>
</div>
</body>
</html>